<template>
  <div class="app-container">
    <div>
      <el-table
        :data="tableData"
        v-loading="loading"
        border
        style="width: 100%"
      >
        <el-table-column
          label="一级指标"
          fixed
          width="150"
          prop="firstLevel"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="二级指标"
          fixed
          width="150"
          prop="secondLevel"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="指标说明及工作内容、工作要求等"
          fixed
          width="300"
          prop="content"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column label="指标单位" width="100" prop="unit">
          <!--          <template #default="scope">-->
          <!--            <dict-tag :options="indicator_unit" :value="scope.row.unit" />-->
          <!--          </template>-->
        </el-table-column>
        <el-table-column
          label="指标值"
          width="100"
          prop="targetValue"
        ></el-table-column>
        <el-table-column
          label="考核评分标准"
          prop="scoreStandard"
          show-overflow-tooltip
          width="200"
        ></el-table-column>
        <el-table-column
          label="分值权重"
          width="120"
          prop="score"
        ></el-table-column>
        <el-table-column
          label="考核人姓名"
          width="120"
          show-overflow-tooltip
          prop="assessorUserName"
        ></el-table-column>
        <el-table-column
          label="考核人部门"
          width="120"
          show-overflow-tooltip
          prop="assessorDeptName"
        ></el-table-column>
        <el-table-column
          label="考核人职务"
          width="120"
          show-overflow-tooltip
          prop="assessorDutiesName"
        ></el-table-column>
        <el-table-column
          label="考核人岗位"
          width="120"
          show-overflow-tooltip
          prop="assessorPostName"
        ></el-table-column>
        <el-table-column
          label="被考核人部门"
          prop="appraiseeDeptName"
          show-overflow-tooltip
          width="120"
        ></el-table-column>
        <el-table-column
          width="120"
          label="被考核人姓名"
          prop="appraiseeUserName"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          width="120"
          label="被考核人岗位"
          prop="appraiseePostName"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          width="120"
          label="被考核人职务"
          show-overflow-tooltip
          prop="appraiseeDutiesName"
        ></el-table-column>
        <el-table-column width="120" label="考核频率" prop="frequency">
          <template #default="scope">
            <dict-tag
              :options="examine_frequency"
              :value="scope.row.frequency"
            />
          </template>
        </el-table-column>
        <el-table-column width="120" label="计分方式" prop="scoreMethod">
          <template #default="scope">
            <dict-tag
              :options="scoring_method"
              :value="scope.row.scoreMethod"
            />
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryForm.pageNum"
        v-model:limit="queryForm.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>
<!-- 指标管理 -->
<script setup name="IndicatorManage">
import { getCurrentInstance } from 'vue'
import {
  deleteBizofficeconf,
  getBizofficeconfList,
  saveBizofficeconfInfo
} from '@/api/officeManage/indicator'
import useCommonStore from '@/store/modules/common'
import useUserStore from '@/store/modules/user'

const userStore = useUserStore()

// 通用数据store
const commonStore = useCommonStore()
const { proxy } = getCurrentInstance()

const data = reactive({
  queryForm: {
    pageSize: 10,
    pageNum: 1,
    appraiseeUser: userStore.user.userId
  },
  tableData: [],
  total: 0,
  loading: false
})
const { queryForm, total, tableData, loading } = toRefs(data)

const { scoring_method, indicator_unit, examine_frequency } = proxy.useDict(
  'scoring_method',
  'indicator_unit',
  'examine_frequency'
)

/**
 * getList 查询方法
 */
const getList = () => {
  loading.value = true
  let params = JSON.parse(JSON.stringify(queryForm.value))
  getBizofficeconfList(params)
    .then(res => {
      total.value = res.data.total
      tableData.value = res.data.records
    })
    .finally(() => {
      loading.value = false
    })
}

/**
 * 初始化
 */
const init = () => {
  getList()
}

init()
</script>
<style lang="scss" scoped>
::v-deep .indicatorDialog {
  border-radius: 10px;
  .el-dialog__header {
    @apply py-5 mr-0 border-b-1 border-b-solid border-gray-200;
  }
  .el-dialog__headerbtn {
    top: 0;
  }
}
</style>
